from word_cloud import WordCloud
import jieba
from PIL import Image
import numpy as np
mask = np.array(Image.open("../data/plane.png"))

txt = '弱小的人,才习惯,嘲讽和否定，而内心,强大的人,从不吝啬赞美和鼓励！我们就是后浪，奔涌吧！后浪，奔涌吧！我喜欢您我喜欢您我喜欢您我喜欢您'
words = jieba.lcut(txt)     #精确分词

wordcloud = WordCloud(background_color="white",
                      width=800,
                      height=600,
                      max_words=200,
                      max_font_size = 80,
                      mask=mask,
                      contour_width=3,\
                      contour_color='steelblue',
                      font_path="../data/ch.ttf",
                      collocations=False
                      ).generate(' '.join(words))
wordcloud.to_file('../out/word_cloud_back.png')

